package chapter04.d1_fileio.demo2;

import chapter04.d1_fileio.demo1.Student;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: jack_yang
 * @Date: 2024/5/8
 * @Description: addition and subtraction
 */
public class FileReaderTest2 {
    public static void main(String[] args) {
        File file = new File("D:\\test.txt");
        Scanner scanner = null;
        try {
            scanner = new Scanner(file);
            scanner.useDelimiter(",");
            List<Student> studentList = new ArrayList<>();
            while (scanner.hasNext()) {
//                System.out.println(scanner.next());
                String[] s = scanner.next().split(" ");
                Student student = new Student(Integer.parseInt(s[0]),s[1]);
                studentList.add(student);
            }
            System.out.println(studentList);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
